package soccer.stats

import com.google.common.base.Objects
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH

class Team {
    String name
    String country
    String teamType

    static hasMany = [
            playerHistories: PlayerHistory,
            teamInfoUrls: TeamInfoUrl
    ]

    static constraints = {
        name nullable: false
        country nullable: true
        teamType nullable: false, inList: CH.config.com.singhanuvrat.soccerstats.teamTypes
    }

    static mapping = {
        cache false
        playerHistories cascade: "all-delete-orphan"
    }

    def String toString() {
        return Objects.toStringHelper(this).add("Name", name).add("Country", country).add("TeamType", teamType).toString()
    }
}
